package uk.ac.aber.Blockmation.Actions;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;

import uk.ac.aber.Blockmation.MainFrame;

/**
 * 
 * @author tom, alex
 */

public class ActionJumpToStart extends AbstractAction {
	
    private MainFrame mainFrame;
    private String path = "../icons/FirstFrame.gif";

    public ActionJumpToStart(MainFrame mainFrame) {
        super("Jump To Start");
        this.mainFrame = mainFrame;
        
        // the below from settings class file or?!
        //putValue(SHORT_DESCRIPTION, tooltip);  // Will appear as tooltip text.
        //putValue(MNEMONIC_KEY, new Integer(mnemonic));
        
    }
        
    public void actionPerformed(ActionEvent e) {

        int index = mainFrame.getCurrentFrameIndex();

    	if (index > 0 ) {
            mainFrame.setCurrentFrameIndex(0);
            mainFrame.getPad().setImage(mainFrame.getMovieModel().get(0));
        } else {
            System.err.println("Cannot go to back any further because this is the first frame!");
        }
    	
    }
    
    public void setImage () {
        CreateImageIcon createImageIcon = new CreateImageIcon();
        putValue(SMALL_ICON, createImageIcon.create(path));
    }


}
